<template>
  <section class="container">
    <img src="../static/img/logo.png" alt="Nuxt.js Logo" class="logo" />
    
  </section>
</template>
<script>
import { mapState } from 'vuex'
export default {
  asyncData ({ req }) {
    return {
      name: req ? 'server' : 'client'
    }
  },
  head () {
    return {
      title: `测试page`
    }
  },
  // 在模板渲染完成后，监听数据时
  beforeMount () {
    const wx = window.wx
    const url = window.location.href
    // 在根实例中注册 store ,子组件能通过 this.$store 访问 store 实例
    // 这一步是为了获取 签名的三参和appid
    this.$store.dispatch('getWechatSignature', url)
      .then(res => {
        if(res.data.success) {
          const params = res.data.params

          wx.config({
            debug: true,
            appId: params.appId,
            nonceStr: params.nonceStr,
            timestamp: params.timestamp,
            jsApiList: [
              'chooseImage',
              'previewImage',
              'uploadImage',
              'downloadImage',
              'onMenuShareTimeline',
              'hideAllNonBaseMenuItem',
              'showMenuItems'
            ]
          })

          wx.ready(() => {
            wx.hideAllNonBaseMenuItem()
            console.log('success')
          })
        }
      })
  }
}
</script>

<style scoped>
.title
{
  margin-top: 50px;
}
.info
{
  font-weight: 300;
  color: #9aabb1;
  margin: 0;
  margin-top: 10px;
}
.button
{
  margin-top: 50px;
}
</style>
